#ifndef VZLPR_ADDON_DEVICEWRAP_H_
#define VZLPR_ADDON_DEVICEWRAP_H_

#include "DeviceManager.h"

extern DeviceManager *g_manager;

class DeviceWrap : public Nan::ObjectWrap {
  friend class JsonObject;
public:
  static NAN_MODULE_INIT(Init);
  static void NewInstance(Nan::NAN_METHOD_ARGS_TYPE info, VzLPRClientHandle handle);

  Device* get();
  VzLPRClientHandle take();

private:
  explicit DeviceWrap(Device* device);
  ~DeviceWrap();

  static Nan::Persistent<v8::Function>& constructor();
  static NAN_METHOD(New);

  static NAN_METHOD(on);
  static NAN_METHOD(getHandle);
  static NAN_METHOD(startReceivePlateResult);
  static NAN_METHOD(stopReceivePlateResult);
  static NAN_METHOD(startRealPlay);
  static NAN_METHOD(stopRealPlay);
  static NAN_METHOD(forceTrigger);
  static NAN_METHOD(queryCountByTimeAndPlate);
  static NAN_METHOD(queryPageRecordByTimeAndPlate);
  static NAN_METHOD(whiteListGetVehicleCount);
  static NAN_METHOD(whiteListLoadVehicle);
  static NAN_METHOD(whiteListImportRows);
  static NAN_METHOD(whiteListDeleteVehicleByID);
  static NAN_METHOD(getWLCheckMethod);
  static NAN_METHOD(getWLFuzzy);

  static NAN_METHOD(getBoardType);
  static NAN_METHOD(getBoardVersion);
  static NAN_METHOD(getParamProperty);
  static NAN_METHOD(getVideoStreamParam);
  static NAN_METHOD(setVideoStreamParam);
  static NAN_METHOD(getVideoOsdParam);
  static NAN_METHOD(setVideoOsdParam);
  static NAN_METHOD(getVideoSourceParam);
  static NAN_METHOD(setVideoSourceParam);

  static NAN_METHOD(getEncryptParam);
  static NAN_METHOD(setEncryptParam);
  static NAN_METHOD(changeEncryptKey);
  static NAN_METHOD(resetEncryptKey);

  static NAN_METHOD(getNetworkParam);
  static NAN_METHOD(setNetworkParam);
  static NAN_METHOD(getSupportedProvinces);
  static NAN_METHOD(getVirtualLoopParam);
  static NAN_METHOD(getRegionOfInterestParam);
  static NAN_METHOD(getUserDefinedParam);

  static NAN_METHOD(getPlateRecognizeType);
  static NAN_METHOD(getPlateTriggerType);

  static NAN_METHOD(getSerialParam);
  static NAN_METHOD(setSerialParam);
  static NAN_METHOD(getRS485PushParam);
  static NAN_METHOD(serialStart);
  static NAN_METHOD(serialStop);
  static NAN_METHOD(serialSend);
  static NAN_METHOD(getOutputParam);
  static NAN_METHOD(getNtpParam);

  static NAN_METHOD(reboot);
  static NAN_METHOD(isConnected);
  static NAN_METHOD(startUpdate);
  static NAN_METHOD(stopUpdate);
  static NAN_METHOD(getUpdateState);
  static NAN_METHOD(getUpdateProgress);

  static NAN_METHOD(getSoftwareVersion);
  static NAN_METHOD(restoreFullConfig);
  static NAN_METHOD(restorePartConfig);
  
  static NAN_METHOD(getGpioState);
  static NAN_METHOD(setGpioState);
  static NAN_METHOD(setGpioRecvCallback);
  static NAN_METHOD(setRequestTalk);

  static NAN_METHOD(getDateTime);
  static NAN_METHOD(setDateTime);

  static NAN_METHOD(getSerialNo);
  static NAN_METHOD(getSerialNum);

  static NAN_METHOD(setUsrDefaultCfg);
  static NAN_METHOD(getUsrDefinedCfg);
  static NAN_METHOD(setUsrDefinedCfg);

  static NAN_METHOD(getEMS);
  
  static NAN_METHOD(tcpRecvStart);

  Device* device_;
};

#endif //  VZLPR_ADDON_DEVICEWRAP_H_
